package org.jeecg.talentCooperation.common;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.talentCooperation.common.vo.Result;
import org.jeecg.talentCooperation.fruit.entity.FruitTalentFieldRel;
import org.jeecg.talentCooperation.fruit.service.IFruitFieldTagRelService;
import org.jeecg.talentCooperation.fruit.service.IFruitService;
import org.jeecg.talentCooperation.fruit.service.IFruitTalentFieldRelService;
import org.jeecg.talentCooperation.talent.model.TalentResultModel;
import org.jeecg.talentCooperation.talent.service.ITalentBasicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/ndTalent/statistics")
public class StatisticsController {

    @Autowired
    private IFruitService fruitService;

    @Autowired
    private IFruitFieldTagRelService fruitFieldTagRelService;

    @Autowired
    private ITalentBasicService talentBasicService;

    /**
     * 数量统计
     * @return
     */
    @RequestMapping(value = "/getNumCount", method = RequestMethod.POST)
    public Result<?> getNumCount() {
        Map<String, Integer> map = new HashMap<>();

        Integer fruitCount = fruitService.count();
        map.put("fruitCount", fruitCount);

        Integer talentCount = talentBasicService.count();
        map.put("talentCount", talentCount);

        return Result.ok(map);
    }


    /**
     * 成果数据图表统计
     * @return
     */
    @RequestMapping(value = "/getFruitDataChart", method = RequestMethod.POST)
    public Result<?> getFruitData() {

        List<TalentResultModel> resultModelList = fruitFieldTagRelService.getFruitDataChart();

        return Result.ok(resultModelList);
    }

}
